// 当前这个模块：API进行统一管理
import requests from "./request";
import mockRequests from "./mockAjax";

// 三级联动接口
export function reqCategoryList() {
  return requests({
    url: "/api/product/getBaseCategoryList",
    method: "get",
  });
}

// 获取banner（Home首页轮播图接口）
export function reqGetBannerList() {
  return mockRequests({
    url: "/mock/banner",
    method: "get",
  });
}

// 获取floor组件的数据
export function reqFloorList() {
  return mockRequests({
    url: "/mock/floor",
    method: "get",
  });
}

// 获取搜素商品数据
export function reqGetSearchList(data) {
  return requests({
    url: "/api/list",
    method: "post",
    data,
  });
}

// 获取产品详情
export function reqGetDetailList(skuId) {
  return requests({
    url: `/api/item/${skuId}`,
    method: "get",
  });
}
// 将产品添加到购物车
export function reqAddOrUpdateShopCart(skuId, skuNum) {
  return requests({
    url: `/api/cart/addToCart/${skuId}/${skuNum}`,
    method: "post",
  });
}

// 获取购物车列表数据

export function reqGartList() {
  return requests({
    url: "/api/cart/cartList",
    method: "get",
  });
}

// 删除购物车商品
export function reqDeleteCartById(skuId) {
  return requests({
    url: `/api/cart/deleteCart/${skuId}`,
    method: "delete",
  });
}

// 改变商品的选中状态

export function reqUpdateCheckedById(skuId, isChecked) {
  return requests({
    url: `/api/cart/checkCart/${skuId}/${isChecked}`,
    method: "get",
  });
}
// 获取验证码
export function reqGetCode(phone) {
  return requests({
    url: `/api/user/passport/sendCode/${phone}`,
    method: "get",
  });
}

// 注册
export function reqUserRegister(data) {
  return requests({
    url: "/api/user/passport/register",
    method: "post",
    data,
  });
}

// 登录
export function reqUserLogin(data) {
  return requests({
    url: "/api/user/passport/login",
    method: "post",
    data,
  });
}

// 获取用户信息 【需要带着用户的token向服务器要用户信息】
export function reqUserInfo() {
  return requests({
    url: "/api/user/passport/auth/getUserInfo",
    method: "get",
  });
}

// 退出登录
export function reqLogout() {
  return requests({
    url: "/api/user/passport/logout",
    method: "get",
  });
}

// 获取用户地址信息
export function reqAddressInfo() {
  return requests({
    url: "api/user/userAddress/auth/findUserAddressList",
    method: "get",
  });
}

// 获取订单交易页信息
export function reqOrderInfo() {
  return requests({
    url: "/api/order/auth/trade",
    method: "get",
  });
}

// 提交订单
export function reqSubmitOrder(tradeNo, data) {
  return requests({
    url: `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: "post",
    data,
  });
}

// 获取订单支付信息
export function reqPayInfo(orderId) {
  return requests({
    url: `/api/payment/weixin/createNative/${orderId}`,
    method: "get",
  });
}

// 获取订单支付状态
export function reqPayStatus(orderId) {
  return requests({
    url: `/api/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
  });
}

// 获取我的订单列表
export function reqMyOrderList(page, limit) {
  return requests({
    url: `/api/order/auth/${page}/${limit}`,
    method: 'get'
  })
}